import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import base from './uitils/common'
import http from './api/http'
import api from './api/pageApi'
import './assets/style/element-theme.scss'
import ElementPlus, { ElDialog } from 'element-plus'
import './assets/element-icon/icon.css'
import './assets/style/index.scss'
//import '@fortawesome/fontawesome-free/css/all.min.css';
import {
  NButton,
  create,
  NDataTable,
  NConfigProvider
} from 'naive-ui'
const naive = create({
  components: [NButton, NDataTable, NConfigProvider],
})
// import 'dayjs/locale/zh-cn'
// import locale from 'element-plus/lib/locale/lang/zh-cn'
import translator from './uitils/translator'
import permission from './api/permission'
import viewgird from './components/basic/ViewGrid'
import ServiceSelect from './components/ServiceSelect'
import SvgIcon from './components/Svg'
import VolEdit from './components/basic/VolEdit.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import * as directives from './uitils/directive/index'
const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注册所有自定义指令
Object.entries(directives).forEach(([key, directive]) => {
  app.directive(key, directive)
})

ElDialog.props.draggable = {
  type: Boolean,
  default: true,
}

import VolSelectBox from './components/basic/VolSelectBox'
import VolSelectTable from './components/basic/VolSelectTable'
translator.init(app)
app.config.globalProperties.base = base
app.config.globalProperties.http = http

// 如果有子页面表格高度取可视高度的一半 - 固定高度
app.config.globalProperties.$HasChildrenPageHeight = document.documentElement.clientHeight / 2 - 190  
app.config.globalProperties.$tabs = {}
app.config.globalProperties.$api = api
app.config.globalProperties.permission = permission
app.config.globalProperties.$global = {
  layout: 'top', //菜单布局方式：classics=经典导航，top=顶部导航,left=侧边导航
  theme: 'classic', //默认布局颜色：classic、dark、blue、red、orange、green
  menuSearch: true, //菜单是否启用搜索功能
  table: {
    smallCell: true, //表格单元格大小
    useTag: true, //table组件下拉框数据源的字段是否显示背景颜色
  },
  border: true,
  lang: true, //是否使用多语言
  labelPosition: 'top', //表单(弹出框表单)标签显示位置,可选值，top、left，2023.07.04
  db: true, //是否使用分库
  signalR: true, //是否开启signalR
  audit: {
    //审核选项
    data: [
      { text: '通过', value: 1 },
      { text: '拒绝', value: 3 },
      { text: '驳回', value: 4 },
    ],
    status: [0, 2], //审核中的数据
    // 待审核 = 0,
    // 审核通过 = 1,
    // 审核中 = 2,
    // 审核未通过 = 3,
    // 驳回 = 4
  },
}

import DeptSelect from './components/DeptSelect'

app
  .use(store)
  .use(ElementPlus, { size: 'default' })
  .use(router)
  .use(DeptSelect)
  .use(ServiceSelect)
  .use(VolEdit)
  .use(viewgird)
  .use(VolSelectBox)
  .use(VolSelectTable)
  .use(SvgIcon)
  .use(naive)
  .mount('#app')
